package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AdminPrizeRecord;
import com.ruoyi.system.service.IAdminPrizeRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 开奖记录Controller
 * 
 * @author ruoyi
 * @date 2020-11-18
 */
@RestController
@RequestMapping("/system/agentPrizeRecord")
public class AgentPrizeRecordController extends BaseController
{
    @Autowired
    private IAdminPrizeRecordService adminPrizeRecordService;

    /**
     * 查询开奖记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:agentPrizeRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdminPrizeRecord adminPrizeRecord)
    {
        startPage();
        List<AdminPrizeRecord> list = adminPrizeRecordService.selectAdminPrizeRecordListToAgent(adminPrizeRecord);
        return getDataTable(list);
    }

    /**
     * 导出开奖记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:agentPrizeRecord:export')")
    @Log(title = "开奖记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdminPrizeRecord adminPrizeRecord)
    {
        List<AdminPrizeRecord> list = adminPrizeRecordService.selectAdminPrizeRecordList(adminPrizeRecord);
        ExcelUtil<AdminPrizeRecord> util = new ExcelUtil<AdminPrizeRecord>(AdminPrizeRecord.class);
        return util.exportExcel(list, "agentPrizeRecord");
    }

    /**
     * 获取开奖记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:agentPrizeRecord:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(adminPrizeRecordService.selectAdminPrizeRecordById(recordId));
    }

    /**
     * 新增开奖记录
     */
    @PreAuthorize("@ss.hasPermi('system:agentPrizeRecord:add')")
    @Log(title = "开奖记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdminPrizeRecord adminPrizeRecord)
    {
        return toAjax(adminPrizeRecordService.insertAdminPrizeRecord(adminPrizeRecord));
    }

    /**
     * 修改开奖记录
     */
    @PreAuthorize("@ss.hasPermi('system:agentPrizeRecord:edit')")
    @Log(title = "开奖记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdminPrizeRecord adminPrizeRecord)
    {
        return toAjax(adminPrizeRecordService.updateAdminPrizeRecord(adminPrizeRecord));
    }

    /**
     * 删除开奖记录
     */
    @PreAuthorize("@ss.hasPermi('system:agentPrizeRecord:remove')")
    @Log(title = "开奖记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(adminPrizeRecordService.deleteAdminPrizeRecordByIds(recordIds));
    }
}
